package com.dbh.company;

import java.util.*;

public class Test2 {
    public static void main(String[] args) {
        // 集合1
        String set1Str = "4511057861085\n" +
                "4511057864160\n" +
                "4511057865987\n" +
                "4511057880802\n" +
                "4511057881868\n" +
                "4511058215513\n" +
                "4511058222930\n" +
                "4511058724401\n" +
                "4511058725838\n" +
                "4511058729118\n" +
                "4511058750640\n" +
                "4511058751785\n" +
                "4511058752086\n" +
                "4511058753816\n" +
                "4511058755783\n" +
                "4511058757026\n" +
                "4511058772164\n" +
                "4511058772377\n" +
                "4511059263934\n" +
                "4511059267497\n" +
                "4511059279327\n" +
                "4511059281052\n" +
                "4511059285836\n" +
                "4511059294414\n" +
                "4511059296283\n" +
                "4511059297098\n" +
                "4511059297334\n" +
                "4511059297607\n" +
                "4511059297908\n" +
                "4511059297967\n" +
                "4511059298417\n" +
                "4511059298491\n" +
                "4511059298589\n" +
                "4511059313619\n" +
                "4511059314854\n" +
                "4511059316308\n" +
                "4511059318626\n" +
                "4511059320529\n" +
                "4511059323735\n" +
                "4511059453225\n" +
                "4511059928757\n" +
                "4511060009788\n" +
                "4511060281854\n" +
                "4511060473387\n" +
                "4511060478353\n" +
                "4511060486945\n" +
                "4511060493944\n" +
                "4511060494451\n" +
                "4511060557074\n" +
                "4511100792687\n" +
                "4511100793594\n" +
                "4511100849802\n" +
                "4511100852724\n" +
                "4511100852910\n" +
                "4511100853241\n" +
                "4511100853975\n" +
                "4511100854019\n" +
                "4511100898999\n" +
                "4511100901461\n" +
                "45000000000276\n" +
                "45000000000386\n" +
                "45000000000446\n" +
                "45000000001699\n" +
                "45000000002429\n" +
                "45000000002856\n" +
                "45000000005056\n" +
                "45000000005056\n" +
                "45000000008425\n" +
                "45000000010377\n" +
                "456941581783299\n" +
                "456942057574346\n" +
                "456944195621613\n" +
                "456944364179638\n" +
                "456945339355293\n" +
                "456946183197423\n" +
                "456950931672647\n" +
                "456988867318173\n" +
                "457007879835766\n" +
                "457009157262721\n" +
                "457009595568108\n" +
                "457011239735043\n" +
                "457011763498747\n" +
                "457012084887078\n" +
                "457012389499095\n" +
                "457013732725169\n" +
                "457031965626427\n" +
                "457098775646004\n" +
                "457099128492587\n" +
                "457101730532996\n" +
                "457102374882638\n" +
                "457102657998773\n" +
                "457103188841102\n" +
                "457103849967516\n" +
                "457103924416222\n" +
                "457104111848507\n" +
                "457104707178420\n" +
                "457418131788341\n" +
                "457419795353898\n" +
                "457419859840614\n" +
                "457419897852163\n" +
                "457420051730457\n" +
                "457420093148548\n" +
                "457420440752932\n" +
                "457420553212826\n" +
                "457421068061804\n" +
                "457421068063118\n" +
                "457421859737978\n" +
                "457422189777202\n" +
                "457422310101113\n" +
                "457424060436568\n" +
                "457425114256093\n" +
                "457425292513707\n" +
                "457425612067796\n" +
                "457425796878379\n" +
                "457462437007755\n" +
                "457462650654803\n" +
                "457467691683949\n" +
                "457467747258662\n" +
                "457484175823865\n" +
                "457485295176901\n" +
                "457485612109802\n" +
                "457486858342838\n" +
                "457487178682538\n" +
                "457488367504626\n" +
                "457490503716409\n" +
                "457508037219162\n" +
                "457509197204710\n" +
                "457512342934248\n" +
                "457573632461919\n" +
                "457574959960261\n" +
                "457575166004804\n" +
                "457575208996317\n" +
                "457576574503944\n" +
                "457576574503954\n" +
                "457578611888391\n" +
                "457626121818496\n" +
                "457643028532808\n" +
                "457665728368874\n" +
                "457741090575180\n" +
                "457741294783908\n" +
                "457741294784001\n" +
                "457741294784046\n" +
                "457743324303375\n" +
                "457804426923894\n" +
                "457823331438908\n" +
                "457851383206502\n" +
                "457853066432752\n" +
                "457857163219054\n" +
                "457876444434423\n" +
                "457877800243564\n" +
                "458012231094438\n" +
                "458053746839945\n" +
                "458054415043668\n" +
                "458055155862787\n" +
                "458055155863178\n" +
                "458055442911887\n" +
                "458099286495477\n" +
                "458103529295746\n" +
                "458139694682229\n" +
                "458169929847162\n" +
                "458170449153882\n" +
                "458187619587051\n" +
                "458233206427342\n" +
                "458254356730746\n" +
                "458276901113383\n" +
                "458367741087780\n" +
                "458376825950805\n" +
                "458436246655919\n" +
                "458645049332128\n" +
                "458787299937544\n" +
                "458825070170572\n" +
                "458934716092388\n" +
                "459092451282166\n" +
                "459096255515917\n" +
                "459120423095992\n" +
                "459544636051416\n" +
                "459591059656073\n" +
                "459706515477479\n" +
                "4510001737854733\n" +
                "4510138324578204\n" +
                "4510138473477021\n" +
                "4510138521972583\n" +
                "4510138689482513\n" +
                "4510163664728842\n" +
                "4510360001146154\n" +
                "4510497364603873\n" +
                "4510952323116096\n" +
                "4511130656271997\n" +
                "4511154494337297\n" +
                "4511248319869690\n" +
                "4511335327296675\n" +
                "4511431977169657\n" +
                "4511517119967574\n" +
                "4511655325166966\n" +
                "4511745320513133\n" +
                "4511810768957202\n" +
                "4512065847127870\n" +
                "4512153217887570\n" +
                "4512519054781922\n" +
                "4512540657806401\n" +
                "4512829598692257\n" +
                "4513091389321098\n" +
                "4513220457492879\n" +
                "4513258553830907\n" +
                "4513783926845998\n" +
                "4514009276576386\n" +
                "4514622409918598\n" +
                "4514916683598965\n" +
                "4514916683599716\n" +
                "4514916920552491\n" +
                "4515054206175748\n" +
                "4516384730082454\n" +
                "4517523950497891\n" +
                "4517973612939993\n" +
                "4518019630722670\n" +
                "4520021404786043\n" +
                "4520022390669176\n" +
                "4520024713229079\n" +
                "4520030383196640\n" +
                "4520034123041466\n" +
                "4520036868102073\n" +
                "4520036934173803\n" +
                "4520037067354061\n" +
                "4520039705037808\n" +
                "4520040006150019\n" +
                "4520042474950626\n" +
                "4520044604161151\n" +
                "4520049065401189";

        // 集合2
        String set2Str = "4511057861085\n" +
                "4511057864160\n" +
                "4511057865987\n" +
                "4511057880802\n" +
                "4511057881868\n" +
                "4511058215513\n" +
                "4511058222930\n" +
                "4511058724401\n" +
                "4511058725838\n" +
                "4511058729118\n" +
                "4511058741522\n" +
                "4511058750640\n" +
                "4511058751785\n" +
                "4511058752086\n" +
                "4511058753816\n" +
                "4511058755783\n" +
                "4511058757026\n" +
                "4511058772164\n" +
                "4511058772377\n" +
                "4511059263934\n" +
                "4511059267497\n" +
                "4511059279327\n" +
                "4511059281052\n" +
                "4511059285836\n" +
                "4511059294414\n" +
                "4511059296283\n" +
                "4511059297098\n" +
                "4511059297334\n" +
                "4511059297607\n" +
                "4511059297908\n" +
                "4511059297967\n" +
                "4511059298417\n" +
                "4511059298491\n" +
                "4511059298589\n" +
                "4511059313619\n" +
                "4511059314854\n" +
                "4511059316308\n" +
                "4511059318626\n" +
                "4511059320529\n" +
                "4511059323735\n" +
                "4511059453225\n" +
                "4511059928757\n" +
                "4511060009788\n" +
                "4511060281854\n" +
                "4511060473387\n" +
                "4511060478353\n" +
                "4511060486945\n" +
                "4511060493944\n" +
                "4511060494451\n" +
                "4511060557074\n" +
                "4511100792687\n" +
                "4511100793594\n" +
                "4511100849802\n" +
                "4511100852724\n" +
                "4511100852910\n" +
                "4511100853241\n" +
                "4511100853975\n" +
                "4511100854019\n" +
                "4511100898999\n" +
                "4511100901461\n" +
                "45000000000276\n" +
                "45000000000386\n" +
                "45000000000446\n" +
                "45000000001699\n" +
                "45000000002429\n" +
                "45000000002856\n" +
                "45000000005056\n" +
                "45000000005056\n" +
                "45000000008425\n" +
                "45000000010377\n" +
                "456941581783299\n" +
                "456942057574346\n" +
                "456944195621613\n" +
                "456944364179638\n" +
                "456945339355293\n" +
                "456946183197423\n" +
                "456950931672647\n" +
                "456988867318173\n" +
                "457007879835766\n" +
                "457009157262721\n" +
                "457009595568108\n" +
                "457011239735043\n" +
                "457011763498747\n" +
                "457012084887078\n" +
                "457012389499095\n" +
                "457013732725169\n" +
                "457031965626427\n" +
                "457098775646004\n" +
                "457099128492587\n" +
                "457101730532996\n" +
                "457102374882638\n" +
                "457102657998773\n" +
                "457103188841102\n" +
                "457103849967516\n" +
                "457103924416222\n" +
                "457104111848507\n" +
                "457104707178420\n" +
                "457418131788341\n" +
                "457419795353898\n" +
                "457419859840614\n" +
                "457419897852163\n" +
                "457420051730457\n" +
                "457420093148548\n" +
                "457420440752932\n" +
                "457420553212826\n" +
                "457421068061804\n" +
                "457421068063118\n" +
                "457421859737978\n" +
                "457422189777202\n" +
                "457422310101113\n" +
                "457424060436568\n" +
                "457425114256093\n" +
                "457425292513707\n" +
                "457425612067796\n" +
                "457425796878379\n" +
                "457462437007755\n" +
                "457462650654803\n" +
                "457467691683949\n" +
                "457467747258662\n" +
                "457484175823865\n" +
                "457485295176901\n" +
                "457485612109802\n" +
                "457486858342838\n" +
                "457487178682538\n" +
                "457488367504626\n" +
                "457490503716409\n" +
                "457508037219162\n" +
                "457509197204710\n" +
                "457512342934248\n" +
                "457573632461919\n" +
                "457574959960261\n" +
                "457575166004804\n" +
                "457575208996317\n" +
                "457576574503944\n" +
                "457576574503954\n" +
                "457578611888391\n" +
                "457626121818496\n" +
                "457643028532808\n" +
                "457665728368874\n" +
                "457741090575180\n" +
                "457741294783908\n" +
                "457741294784001\n" +
                "457741294784046\n" +
                "457743324303375\n" +
                "457804426923894\n" +
                "457823331438908\n" +
                "457851383206502\n" +
                "457853066432752\n" +
                "457857163219054\n" +
                "457876444434423\n" +
                "457877800243564\n" +
                "458012231094438\n" +
                "458053746839945\n" +
                "458054415043668\n" +
                "458055155862787\n" +
                "458055155863178\n" +
                "458055442911887\n" +
                "458099286495477\n" +
                "458103529295746\n" +
                "458139694682229\n" +
                "458169929847162\n" +
                "458170449153882\n" +
                "458187619587051\n" +
                "458233206427342\n" +
                "458254356730746\n" +
                "458276901113383\n" +
                "458367741087780\n" +
                "458376825950805\n" +
                "458436246655919\n" +
                "458645049332128\n" +
                "458787299937544\n" +
                "458825070170572\n" +
                "458934716092388\n" +
                "459092451282166\n" +
                "459096255515917\n" +
                "459120423095992\n" +
                "459544636051416\n" +
                "459591059656073\n" +
                "459706515477479\n" +
                "4510001737854733\n" +
                "4510138324578204\n" +
                "4510138473477021\n" +
                "4510138521972583\n" +
                "4510138689482513\n" +
                "4510163664728842\n" +
                "4510360001146154\n" +
                "4510497364603873\n" +
                "4510952323116096\n" +
                "4511130656271997\n" +
                "4511154494337297\n" +
                "4511248319869690\n" +
                "4511335327296675\n" +
                "4511431977169657\n" +
                "4511517119967574\n" +
                "4511655325166966\n" +
                "4511745320513133\n" +
                "4511810768957202\n" +
                "4512065847127870\n" +
                "4512153217887570\n" +
                "4512519054781922\n" +
                "4512540657806401\n" +
                "4512829598692257\n" +
                "4513091389321098\n" +
                "4513220457492879\n" +
                "4513258553830907\n" +
                "4513783926845998\n" +
                "4514009276576386\n" +
                "4514622409918598\n" +
                "4514916683598965\n" +
                "4514916683599716\n" +
                "4514916920552491\n" +
                "4515054206175748\n" +
                "4516384730082454\n" +
                "4517523950497891\n" +
                "4517973612939993\n" +
                "4518019630722670\n" +
                "4520021404786043\n" +
                "4520022390669176\n" +
                "4520024713229079\n" +
                "4520030383196640\n" +
                "4520034123041466\n" +
                "4520036868102073\n" +
                "4520036934173803\n" +
                "4520037067354061\n" +
                "4520039705037808\n" +
                "4520040006150019\n" +
                "4520042474950626\n" +
                "4520044604161151\n" +
                "4520049065401189";

        // 解析集合1
        Set<String> set1 = parseSet(set1Str);
        System.out.println("集合1数量: " + set1.size());
        
        // 解析集合2
        Set<String> set2 = parseSet(set2Str);
        System.out.println("集合2数量: " + set2.size());
        System.out.println();
        
        // 找出集合1中有但集合2中没有的（差集：set1 - set2）
        Set<String> onlyInSet1 = new TreeSet<>(set1);
        onlyInSet1.removeAll(set2);
        
        // 找出集合2中有但集合1中没有的（差集：set2 - set1）
        Set<String> onlyInSet2 = new TreeSet<>(set2);
        onlyInSet2.removeAll(set1);
        
        System.out.println("=== 集合对比结果 ===");
        System.out.println();
        
        System.out.println("在集合1中但不在集合2中的数字 (" + onlyInSet1.size() + " 个):");
        if (onlyInSet1.isEmpty()) {
            System.out.println("  无");
        } else {
            for (String num : onlyInSet1) {
                System.out.println("  " + num);
            }
        }
        
        System.out.println();
        System.out.println("在集合2中但不在集合1中的数字 (" + onlyInSet2.size() + " 个):");
        if (onlyInSet2.isEmpty()) {
            System.out.println("  无");
        } else {
            for (String num : onlyInSet2) {
                System.out.println("  " + num);
            }
        }
        
        System.out.println();
        System.out.println("=== 统计信息 ===");
        System.out.println("集合1去重后数量: " + set1.size());
        System.out.println("集合2去重后数量: " + set2.size());
        System.out.println("交集数量（两个集合都有的）: " + (set1.size() - onlyInSet1.size()));
        System.out.println("只在集合1中的数量: " + onlyInSet1.size());
        System.out.println("只在集合2中的数量: " + onlyInSet2.size());
    }
    
    /**
     * 解析字符串为Set集合
     */
    private static Set<String> parseSet(String str) {
        Set<String> set = new LinkedHashSet<>();
        String[] lines = str.split("\n");
        for (String line : lines) {
            String trimmed = line.trim();
            if (!trimmed.isEmpty()) {
                set.add(trimmed);
            }
        }
        return set;
    }
}
